//
//  BadgeValue.m
//  Weibo
//
//  Created by Anasue on 9/21/15.
//  Copyright (c) 2015 Anasue. All rights reserved.
//

#import "BadgeValueView.h"

@implementation BadgeValueView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.titleLabel.font = [UIFont systemFontOfSize:11];
        [self setBackgroundImage:[UIImage resizeImage:@"main_badge"] forState:UIControlStateNormal];
        self.height = self.currentBackgroundImage.size.height;
    }
    return self;
}

- (void)setBadgeValue:(NSString *)badgeValue
{
    _badgeValue = badgeValue;
    
    [self setTitle:badgeValue forState:UIControlStateNormal];
//    Log(@"%@",badgeValue);
    
    CGSize textSize = [badgeValue sizeWithFont:self.titleLabel.font];
    CGFloat bgW = self.currentBackgroundImage.size.width;
    if (textSize.width > bgW) {
        self.width = textSize.width + 10;
    }else{
        self.width = bgW;
    }
//    Log(@"%@",NSStringFromCGSize(textSize));
    
}

@end
